package com.mybatis.dao;

import com.mybatis.pojo.Flysysuser;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;

import java.io.InputStream;

/**
 * @author Pretty·Boy
 * @date 2018/12/18 7:49
 */
public class Test {

    private SqlSessionFactory sqlSessionFactory;

    @Before
    public void init() throws Exception{
        SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
        InputStream resourceAsStream = Resources.getResourceAsStream("mybatis.xml");
        sqlSessionFactory = sqlSessionFactoryBuilder.build(resourceAsStream);
    }

    @org.junit.Test
    public void testGetUserById() {
        UserDao userDao = new UserDaoImpl(sqlSessionFactory);
        Flysysuser user = userDao.getUserByid();
        System.out.println("user = " + user);
    }

}
